#ifndef HTTPMGR_H
#define HTTPMGR_H
#include "Singleton.h"
#include <QNetworkAccessManager>
#include <QUrl>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QObject>
#include <QJsonObject>
#include <QJsonDocument>
#include "global.h"


//CRTP 奇异递归模板模式
class HttpMgr:public QObject,public Singleton<HttpMgr>,
        public std::enable_shared_from_this<HttpMgr>
{
    Q_OBJECT
public:
    friend class Singleton<HttpMgr>;
    ~HttpMgr()=default;
    void PostHttpReq(QUrl url,QJsonObject json,ReqId req_id, Modules mod);

private:


private:
    HttpMgr();
    QNetworkAccessManager _manager;


signals:
    //http发送完之后发送这个信号给其他模块，让其他模块做界面上的显示
    void sig_http_finish(ReqId req_id,QString res,ErrorCodes err,Modules mod);
    void sig_reg_mod_finish(ReqId req_id,QString res,ErrorCodes err);
    void sig_reset_mod_finish(ReqId req_id,QString res,ErrorCodes err);
private slots:
    void slot_http_finish(ReqId req_id,QString res,ErrorCodes err,Modules mod);
};

#endif // HTTPMGR_H
